﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Collections;
using System.Diagnostics;
using System.Xml.Serialization;
using TratamentoRIWikipedia.processamento;
using System.IO;
using TratamentoRIWikipedia.Indexacao;
using TratamentoRIWikipedia.modelagem;
using System.Windows.Forms;

namespace TratamentoRIWikipedia
{
    class Program
    {
        public static Stopwatch IniMedTempo()
        {
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();
            return stopWatch;
        }

        public static string FinazMedTempo(Stopwatch stopWatch, string nomeEtapa)
        {
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
            //Console.WriteLine("* Tempo total para " + nomeEtapa + ": " + elapsedTime);
            //Console.WriteLine("*                                                                 *");

            return elapsedTime;
        }

        static void Main()
        {
            //Stopwatch stopWatch = IniMedTempo();

            //Console.WriteLine("****************** Estatítica de Processamento ********************");
            //Console.WriteLine("*                                                                 *");
            //Stopwatch stopWatch0 = IniMedTempo();


            //#region Parse XML + Remoção de caracteres especiais e acentos
            //string arquivoXml = "ptwiki-latest-pages-articles1.xml";
            //ParseXml.ParserXmlDoc(arquivoXml); //ParserXmlDoc (completo com a  Analise Lexica)
            //FinazMedTempo(stopWatch, "parse com analise lexica");
            //#endregion

            //#region Monta lista de ocorrencia para remover stop words
            //Stopwatch stopWatch2 = IniMedTempo();
            //StreamReader Arquivo = new StreamReader("WikiDoc01.txt", System.Text.Encoding.Default);
            //Dictionary<string, int> listOcorrencia = Stopwords.MontaListaOcorrencia(Arquivo);
            //Arquivo.Close();
            //FinazMedTempo(stopWatch2, "montar a lista de stop words");
            //#endregion

            //#region Remove stop Words
            //Stopwatch stopWatch3 = IniMedTempo();
            //ArrayList stopWords = Stopwords.LeiZif(listOcorrencia);
            //StreamReader Arquivo1 = new StreamReader("WikiDoc01.txt", System.Text.Encoding.Default);
            //Stopwords.RemoveStopWords(Arquivo1, stopWords); //Gera o arquivo sem stop words o WikiDocSemStopWord.txt
            //FinazMedTempo(stopWatch3, "remover as stop Words");
            //Arquivo1.Close();
            //#endregion

            //#region Gera Indice a partir do arquivo sem stop word WikiDocSemStopWord.txt
            //Stopwatch stopWatch4 = IniMedTempo();
            //Indice.GeraIndice();
            //FinazMedTempo(stopWatch4, "gerar o indice");
            //#endregion

            //Console.WriteLine("*******************************************************************");
            //Console.WriteLine("*                                                                 *");
            //FinazMedTempo(stopWatch0, "execucação do processamento");
            //Console.WriteLine("*******************************************************************");

            //Form
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmWikiBusca());

            //#region Busca Boleana
            //Console.WriteLine("\n" + "*********************** Modelo Boleanao ***************************" + "\n");

            ////int novaBusca = 1;
            ////Stopwatch stopWatch5 = IniMedTempo();
            ////while (novaBusca == 1)
            ////{
            ////    Console.Write("Digite a sua busca => ");
            ////    string palavrasBuscadas = Console.ReadLine();
            ////    // ModeloBoleano.BuscaBinaria(palavrasBuscadas);
            ////    ModeloVetorial.BuscaVetorial(palavrasBuscadas);

            ////    Console.WriteLine();
            ////    Console.Write("digite enter para nova busca");
            ////    Console.ReadKey();
            ////    Console.Clear();
            ////}

            ////FinazMedTempo(stopWatch5, "busca boleana");
            //#endregion

            ////Console.ReadKey();
        }
    }
}
